package com.hisan.waimaidao.carvas;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 绘制圆形
 */
public class DrawView extends View {
    public DrawView(Context context) {
        super(context);
    }

    public DrawView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrawView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint=new Paint();
        //设置抗拒齿
        paint.setAntiAlias(true);
        paint.setColor(Color.RED);
        //画笔样式为空心时，设置空心画笔的宽度
        paint.setStrokeWidth(20);
        /**
         * 3种模式 STROKE：边缘填充
         * FILL:充满
         * FILL_AND_STROKE:2种结合
         */
        paint.setStyle(Paint.Style.STROKE);
        //虚线宽度
        paint.setStrokeWidth(5);
        canvas.drawCircle(100,100,20,paint);
        canvas.drawCircle(100,100,40,paint);
    }
}
